﻿using DICOMViewer.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DICOMViewer.UC
{
    public partial class LocalSettingForm : Form
    {
        public LocalSettingForm()
        {
            InitializeComponent();
        }

        private ClientConfig clientConfig;

        public LocalSettingForm(ClientConfig config):this()
        {
            clientConfig = config;
            this.tbxAETitle.Text = config.AETitle;
            this.tbxPort.Text = config.Port.ToString();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            int portVal;
            bool portValid = int.TryParse(tbxPort.Text, out portVal);
            if (!portValid)
            {
                MessageBox.Show("端口号不合法！请重新输入！");
                return;
            }
            clientConfig.AETitle = this.tbxAETitle.Text;
            clientConfig.Port = portVal;
            Utility.ComSettingReader.SaveClientConfig(clientConfig);
            this.DialogResult = DialogResult.OK;
        }
    }
}
